<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once("Core.php");

//define('API_URL','http://multicolorengine.tineye.com/jack_studio');
define('API_URL','http://104.224.128.201/api.php?act=');

class CI_Tineye extends CI_Core{
	
	public function upload($url,$name){
		$arr=array('image'=>curl_file_create($url), 'name'=>$name);
		return $this->curl_post(API_URL.'upload_file',$arr);
		//echo $this->curl_get(API_URL.'upload_file&url='.$url.'&name='.$name);
	}
	public function count(){
		echo $this->curl_get(API_URL.'count');
	}
	
	//查找图片URL
	public function search_file($file){
		$rs=json_decode($this->curl_post(API_URL.'search_file',array('image'=>curl_file_create($file),'offset'=>0,'limit'=>100)),true);
		//print_r($rs);exit;
		return $rs['result'];
	}
	
	public function search_color($v){
		#echo $v;exit;
		$rs=json_decode($this->curl_get(API_URL.'search_color&colors='.$v),true);
		return $rs['result'];
	}
	public function delete($v){
		$rs=json_decode($this->curl_get(API_URL.'delete&name='.$v),true);
		return $rs;
	}
	public function piclist($offset=0,$limit=40){
		$rs=json_decode($this->curl_get(API_URL.'list&offset='.$offset.'&limit='.$limit),true);
		return $rs;
	}
	
//	public function upload($image,$filename,$extra){
//		$arr = array('filepath'=>$filename,'image'=>$image);
//		if($extra) $arr['metadata']=$extra;
//		echo $this->curl_post(API_URL.'/rest/add/',$arr);
//	}
//	public function count(){
//		echo $this->curl_get(API_URL.'/rest/count/');
//	}
//	public function get($filename){	
//		echo $this->curl_get(API_URL.'/query/?filepath='.$filename);
//	}
//	public function search(){
//		
//	}
}




